import { LogLevel, LoggerService } from "@nestjs/common";
import { createLogger, format, Logger, transports } from 'winston'
import * as chalk from 'chalk'
import * as dayjs from 'dayjs'

export class MyLogger implements LoggerService{

    private logger: Logger

    constructor(options) {
        this.logger = createLogger(options)
    }

    log(message: string, context: string) {
        const time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss');

        this.logger.log('info', message, { context, time });
    }

    error(message: string, context: string) {
        const time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss');

        this.logger.log('info', message, { context, time });
    }

    warn(message: string, context: string) {
        const time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss');

        this.logger.log('info', message, { context, time });
    }
    debug(message: string, context: string) {
        const time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss');

        this.logger.debug('debug', message, { context, time });
    }
}